package com.bestcem.xm.user.entity.base;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author Linked <zhijian.lin@idiaoyan.com>
 * @version v1.0
 * @date 2021/12/30 14:26
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class PageParam {
    /**
     * 当前页
     */
    @NotNull(message = "当前页不能为空")
    @Min(value = 0, message = "当前页不能小于1")
    private Integer page;

    /**
     * 分页大小
     */
    @NotNull(message = "分页大小不能为空")
    @Min(value = 0, message = "分页大小不能小于1")
    @Max(value = 1000, message = "分页大小不能大于1000")
    private Integer size;


    public Integer getOffset() {
        return (page - 1) * size;
    }

    public Integer getPage() {
        return page;
    }

    public Integer getSize() {
        return size;
    }
}
